#!/usr/bin/env python
# encoding: utf-8
"""
main.py

Created by Pablo Ortega Mesa on 2011-04-05.
Copyright (c) 2011 __MyCompanyName__. All rights reserved.
"""

import sys
import os
import getopt
from FCA import *
from TFIDF import *


options, remainder = getopt.getopt(sys.argv[1:], 'p:t:c:', ['path=', 
                                                         'terms=',  
														 'context=',
														 'threshold='])

path = False
terms = False
context = False
threshold = 0
for opt, arg in options:
	if opt in ('-p','--path'):
		path = arg
	if opt in ('-t','--terms'):
		terms = arg
	if opt in ('-c', '--context'):
		context = arg
	if opt in ('--threshold'):
		threshold = float(arg)


if path and terms:
	fca = FCA(terms,path)
	tfidf = TFIDF(fca.getDocs(),fca.getTerms(),fca.getFreq())
	if context:
		fca.writeContext(context,tfidf.getTFIDF(),threshold)
	
